home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / misc / 563 / settime / settime.gfa (.txt) < prev    next >
Encoding:
GFA-BASIC Atari  |  1991-08-23  |  7.3 KB  |  140 lines

  1. $m10000                                               ! Compiler option to use
  2. '                                                       only 10k of memory.
  3. LET tree1&=0 !RSC_TREE                                  These Variables are
  4. LET setdate&=1 !Obj in #0                               created by the Resource
  5. LET settime&=2 !Obj in #0                               Constuction Set (RSC)
  6. LET setok&=3 !Obj in #0                                 and are written as a
  7. LET tree2&=1 !RSC_TREE                                  *.LST file and merged
  8. LET viewdate&=1 !Obj in #1                              into the program source
  9. LET viewtime&=2 !Obj in #1
  10. LET viewok&=3 !Obj in #1
  11. LET reset&=4 !Obj in #1
  12. IF RSRC_LOAD("SETTIME.RSC")=0                         ! Find the RSC file
  13.   ALERT 1,"SETTIME.RSC| NOT FOUND",1,"ABORT",button#   ! Can't find it, notify
  14.   '                                                     the user.
  15.   END                                                 ! Stop program
  16. ENDIF
  17. MODE 1                                                ! Set date format to U.S.
  18. ~RSRC_GADDR(0,tree1&,input%)                          ! Get the address of the
  19. '                                                       first Object Tree.
  20. '                                                       (input box)
  21. ~FORM_CENTER(input%,x%,y%,w%,h%)                      ! Center the input box
  22. '                                                       on the screen.  The
  23. '                                                       nice thing about this
  24. '                                                       is it does the
  25. '                                                       calculation for each
  26. '                                                       resolution for you.
  27. ~RSRC_GADDR(0,tree2&,output%)                         ! Get the address of the
  28. '                                                       second Object Tree.
  29. '                                                       (verification box)
  30. ~FORM_CENTER(output%,x%,y%,w%,h%)                     ! Center it
  31. GET x%,y%,x%+w%,y%+h%,rsc_screen_area$                ! Save what will be
  32. '                                                       overwitten by the
  33. '                                                       dialog box. It is up to
  34. '                                                       the programer to put the
  35. '                                                       screen back the way it
  36. '                                                       was befor the box
  37. '                                                       appeared.
  38. set_it:                                               ! Major sin...using a GOTO
  39. @get_date_time                                        ! What time is it now?
  40. CHAR{{OB_SPEC(input%,setdate&)}}=date_$               ! Move the current date
  41. CHAR{{OB_SPEC(input%,settime&)}}=time_$               ! and time into the dialog
  42. '                                                       box.
  43. ~FORM_DIAL(1,0,0,0,0,x%,y%,w%,h%)                     ! This makes the box
  44. '                                                       appear to expand from
  45. '                                                       the center.
  46. ~OBJC_DRAW(input%,tree1&,1,x%,y%,w%,h%)               ! Display the box
  47. ~FORM_DO(input%,0)                                    ! This takes your input.
  48. '                                                       believe it or not this
  49. '                                                       one line does it all.
  50. ~OBJC_CHANGE(input%,setok&,0,x%,y%,w%,z%,0,1)         ! We need to redraw the
  51. '                                                       box in case we decide to
  52. '                                                       reset the clock.  If we
  53. '                                                       reset this keeps the
  54. '                                                       OK button from appearing
  55. '                                                       filled.
  56. PUT x%,y%,rsc_screen_area$                            ! Redraw original screen.
  57. ~FORM_DIAL(2,0,0,0,0,x%,y%,w%,h%)                     ! Now make the box
  58. '                                                       disappear into the
  59. '                                                       monitor (shrink).
  60. time_$=CHAR{{OB_SPEC(input%,settime&)}}               ! Put the inputs into
  61. date_$=CHAR{{OB_SPEC(input%,setdate&)}}               ! variables.
  62. ' ----------------------------------------------------------------------------
  63. month$=LEFT$(date_$,2)
  64. day$=MID$(date_$,3,2)
  65. year$=RIGHT$(date_$,2)
  66. date_$=month$+"/"+day$+"/"+year$
  67. hour$=LEFT$(time_$,2)
  68. minute$=MID$(time_$,3,2)                              ! Figure out the inputs
  69. ampm$=RIGHT$(time_$,1)                                ! and configure them for
  70. IF ampm$="A" OR ampm$="a"                             ! the SETTIME command
  71.   IF hour$="12"
  72.     hour$="00"
  73.   ENDIF
  74. ELSE
  75.   hour&=VAL(hour$)
  76.   ADD hour&,12
  77.   IF hour&=24
  78.     hour$="12"
  79.   ELSE
  80.     hour$=STR$(hour&)
  81.   ENDIF
  82. ENDIF
  83. time_$=hour$+":"+minute$+":"+"00"
  84. ' ----------------------------------------------------------------------------
  85. SETTIME time_$,date_$                                 ! Set the date and time
  86. '                                                       If the inputs are not
  87. '                                                       valid the date or time
  88. '                                                       will not change, thus
  89. '                                                       we have a reset option.
  90. @get_date_time                                        ! What time is it now?
  91. CHAR{{OB_SPEC(output%,viewdate&)}}=date_$             ! Move the current date
  92. CHAR{{OB_SPEC(output%,viewtime&)}}=time_$             ! and time to the dialog
  93. '                                                       box.
  94. ~FORM_DIAL(1,0,0,0,0,x%,y%,w%,h%)                     ! Expand box.
  95. ~OBJC_DRAW(output%,0,tree2&,x%,y%,w%,h%)              ! Draw box.
  96. button&=FORM_DO(output%,0)                            ! Store button selected.
  97. ~OBJC_CHANGE(output%,button&,0,x%,y%,w%,z%,0,1)       ! Restore button
  98. '                                                       selected.
  99. PUT x%,y%,rsc_screen_area$                            ! Redraw original screen.
  100. ~FORM_DIAL(2,0,0,0,0,x%,y%,w%,h%)                     ! Shrink box.
  101. IF button&=4                                          ! If reset was selected,
  102.   GOTO set_it                                         ! here it comes, -GOTO-
  103. ENDIF                                                 ! to reset date and time.
  104. ~RSRC_FREE()                                          ! Important, you must
  105. '                                                     ! return memory used by
  106. '                                                     ! the RSRC_LOAD command
  107. '                                                     ! to the system.
  108. END                                                   ! Stop program.
  109. '
  110. PROCEDURE get_date_time                               ! Since I need to get the
  111.   '                                                     date and time twice in
  112.   '                                                     the program flow I use
  113.   '                                                     this subroutine to do
  114.   '                                                     it.
  115.   month$=LEFT$(DATE$,2)
  116.   day$=MID$(DATE$,4,2)                                ! Set up the date for the
  117.   year$=RIGHT$(DATE$,2)                               ! dialog box.
  118.   date_$=month$+day$+year$
  119.   hour$=LEFT$(TIME$,2)                                ! Set up the time for the
  120.   minute$=MID$(TIME$,4,2)                             ! dialog box.
  121.   hour&=VAL(hour$)
  122.   IF hour&=0
  123.     hour&=12
  124.     ampm$="A"
  125.   ELSE IF hour&=12
  126.     ampm$="P"
  127.   ELSE IF hour&>12
  128.     SUB hour&,12
  129.     ampm$="P"
  130.   ELSE
  131.     ampm$="A"
  132.   ENDIF
  133.   hour$=STR$(hour&)
  134.   n&=LEN(hour$)
  135.   IF n&=1
  136.     hour$="0"+hour$
  137.   ENDIF
  138.   time_$=hour$+minute$+ampm$
  139. RETURN
  140.